import { createRouter, createWebHistory } from 'vue-router'
import LayoutView from '../views/layout.vue'
import HomeView from '../views/HomeView.vue'

const  routes = [
    {
      path: '/',
      name: 'index',
      component: LayoutView,
	  redirect:'/home',
	  children:[
	        {
	          path: '/home',
	          name: 'home',
	          // route level code-splitting
	          // this generates a separate chunk (about.[hash].js) for this route
	          // which is lazy-loaded when the route is visited.
	          component: () => import('../views/HomeView.vue')
	        },
			{
			  path: '/about',
			  name: 'about',
			  component: () => import('../views/AboutView.vue')
			},
			{
			  path: '/testview',
			  name: 'testview',
			  component: () => import('../views/testview.vue')
			},
			{
				path: "/404",
				component: () => import("../views/ErrorPage.vue")
			},
			{
			    path: "/:catchAll(.*)", // 不识别的path自动匹配404
			    redirect: '/404',
			},
	      ]
    },
	{
	  path: '/login',
	  name: 'login',
	  hidden: true,
	  component: () => import('../views/login.vue')
	},
    
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

export default router
